class CommentsController < ApplicationController
  include AuthenticatedSystemBrowse
  
  def index
    @comments = Comment.paginate :page => params[:page], :order => "created_at desc"
    @page_title ="意见列表"
  end
  
  def new
    @comment = Comment.new
    @page_title ="新的意见"
  end
  
  def create
    @comment  = Comment.new(params[:comment])
    @comment.user = current_user unless current_user.nil?
    @comment.ip_addr = request.remote_addr
    @comment.save!
    redirect_to comments_url
  rescue ActiveRecord::RecordInvalid
    render :action => 'new'
  end
  
end
